/****** Object:  Database eDASexpress    Script Date: 2009-9-9 9:31:25 ******/
CREATE DATABASE [eDASexpress]  ON (NAME = N'eDASexpress', FILENAME = N'C:\Program Files\eDASexpress\Database\eDASexpress.mdf' , SIZE = 2, FILEGROWTH = 10%) LOG ON (NAME = N'eDASexpress_log', FILENAME = N'C:\Program Files\eDASexpress\Database\eDASexpress_log.ldf' , FILEGROWTH = 10%)
 COLLATE Chinese_PRC_CI_AS
GO

exec sp_dboption N'eDASexpress', N'autoclose', N'false'
GO

exec sp_dboption N'eDASexpress', N'bulkcopy', N'false'
GO

exec sp_dboption N'eDASexpress', N'torn page detection', N'true'
GO

exec sp_dboption N'eDASexpress', N'read only', N'false'
GO

exec sp_dboption N'eDASexpress', N'dbo use', N'false'
GO

exec sp_dboption N'eDASexpress', N'single', N'false'
GO

exec sp_dboption N'eDASexpress', N'autoshrink', N'true'
GO

exec sp_dboption N'eDASexpress', N'ANSI null default', N'false'
GO

exec sp_dboption N'eDASexpress', N'recursive triggers', N'false'
GO

exec sp_dboption N'eDASexpress', N'ANSI nulls', N'false'
GO

exec sp_dboption N'eDASexpress', N'concat null yields null', N'false'
GO

exec sp_dboption N'eDASexpress', N'cursor close on commit', N'false'
GO

exec sp_dboption N'eDASexpress', N'default to local cursor', N'false'
GO

exec sp_dboption N'eDASexpress', N'quoted identifier', N'false'
GO

exec sp_dboption N'eDASexpress', N'ANSI warnings', N'false'
GO

exec sp_dboption N'eDASexpress', N'auto create statistics', N'true'
GO

exec sp_dboption N'eDASexpress', N'auto update statistics', N'true'
GO

if( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) )
	exec sp_dboption N'eDASexpress', N'db chaining', N'false'
GO

use [eDASexpress]
GO

/****** Object:  Table [dbo].[KDepartment]    Script Date: 2009-9-9 9:31:26 ******/
CREATE TABLE [dbo].[KDepartment] (
	[Dept] [varchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[AddTime] [datetime] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KLog]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KLog] (
	[OID] [int] IDENTITY (1, 1) NOT NULL ,
	[Username] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
	[DoType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[DoContent] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[Result] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
	[InDate] [datetime] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KOption]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KOption] (
	[OptName] [varchar] (64) COLLATE Chinese_PRC_CI_AS NULL ,
	[OptValue] [varchar] (512) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KRadius]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KRadius] (
	[IP] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[IPDESC] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[SHAREKEY] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[InTime] [datetime] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KSetup]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KSetup] (
	[ParaName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[ParaValue] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KTokens]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KTokens] (
	[Sn] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[SDB] [image] NULL ,
	[Len] [int] NULL ,
	[Type] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Dept] [varchar] (200) COLLATE Chinese_PRC_CI_AS NULL ,
	[Operator] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
	[Status] [varchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
	[InitDate] [datetime] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[KOperators]    Script Date: 2009-9-9 9:31:27 ******/
CREATE TABLE [dbo].[KOperators] (
	[Username] [varchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Dept] [varchar] (200) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserDesc] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
	[TokenSn] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[TokenSnBak] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[Rights] [char] (6) COLLATE Chinese_PRC_CI_AS NULL ,
	[AddTime] [datetime] NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[KDepartment] WITH NOCHECK ADD 
	CONSTRAINT [PK_KDepartment] PRIMARY KEY  CLUSTERED 
	(
		[Dept]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[KOperators] WITH NOCHECK ADD 
	CONSTRAINT [PK_KOperators] PRIMARY KEY  CLUSTERED 
	(
		[Username],
		[Dept]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[KDepartment] ADD 
	CONSTRAINT [DF_KDepartment_AddTime] DEFAULT (getdate()) FOR [AddTime]
GO

ALTER TABLE [dbo].[KLog] ADD 
	CONSTRAINT [DF_KLog_InDate] DEFAULT (getdate()) FOR [InDate]
GO

ALTER TABLE [dbo].[KRadius] ADD 
	CONSTRAINT [DF_KRadius_InTime] DEFAULT (getdate()) FOR [InTime]
GO

ALTER TABLE [dbo].[KOperators] ADD 
	CONSTRAINT [DF_KOperators_AddTime] DEFAULT (getdate()) FOR [AddTime]
GO

ALTER TABLE [dbo].[KTokens] ADD 
	CONSTRAINT [DF_KTokens_InitDate] DEFAULT (getdate()) FOR [InitDate]
GO

ALTER TABLE [dbo].[KOperators] ADD 
	CONSTRAINT [FK_KOperators_KDepartment] FOREIGN KEY 
	(
		[Dept]
	) REFERENCES [dbo].[KDepartment] (
		[Dept]
	) ON UPDATE CASCADE 
GO
